package me.zhengjie.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * @author yin_qingqin@163.com
 * @Description: 返回值封装
 * @date 2020/7/8 23:55
 */
public class Apis {

    /**
     * 无返回值
     * @return
     */
    public static ResponseEntity R(){
        return new ResponseEntity<>(HttpStatus.OK);
    }

    /**
     * 有返回值
     * @return
     */
    public static ResponseEntity R(Object obj){
        return new ResponseEntity<>(obj, HttpStatus.OK);
    }

    /**
     * 有返回值
     * @return
     */
    public static ResponseEntity R(Object obj, HttpStatus httpStatus){
        return new ResponseEntity<>(obj, httpStatus);
    }

    /**
     * 自定义响应码
     * @return
     */
    public static ResponseEntity R(HttpStatus httpStatus) {
        return new ResponseEntity<>(httpStatus);
    }

    /**
     * 返回body响应体
     * @param obj
     * @return
     */
    public static ResponseEntity OK(Object obj){
        return ResponseEntity.ok(obj);
    }

}
